#include<bits/stdc++.h>
using namespace std;
const int N=505;

int n,m,tot;
vector<int> edges[N];
double cur[N];

int ans=INT_MAX;
bool visit[N];
void dfs(int s,int len,int minw){
    if(s==n){
        ans=min(ans,len+tot/minw);
        return;
    }
    if(len+tot/minw>ans) return;

    for(int i=0;i<edges[s].size();i+=3){
        int t=edges[s][i];
        if(!visit[t]){
            visit[t]=true;
            dfs(t,len+edges[s][i+1],min(minw,edges[s][i+2]));
            visit[t]=false;
        }
    }
}

int main()
{
    scanf("%d%d%d",&n,&m,&tot);
    if(n==1){
        printf("0");
        return 0;
    }
    for(int i=0;i<m;i++){
        int s,t,de,c;
        scanf("%d%d%d%d",&s,&t,&de,&c);
        edges[s].emplace_back(t);
        edges[s].emplace_back(de);
        edges[s].emplace_back(c);

        edges[t].emplace_back(s);
        edges[t].emplace_back(de);
        edges[t].emplace_back(c);
    }
    visit[1]=true;
    dfs(1,0,INT_MAX);
    printf("%d",ans);
    return 0;
}